<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组案例</title>
    <script>
        // 删除为0的元素，形成新数组
        var arr1 = [2, 0, 6, 1, 77, 52, 0, 25, 7];
        var newArr1 = [];
        for (var i = 0; i < arr1.length; i++) {
            if (arr1[i] == 0) {
                continue;
            }
            newArr1[newArr1.length] = arr1[i];
        }
        console.log(newArr1);
        // 反转数组
        var arrStr2 = ['red', 'green', 'blue', 'pink'];
        var newArr2 = [];
        // for (var j = 0; j < arrStr2.length; j++) {
        //     newArr2[newArr2.length] = arrStr2[arrStr2.length - 1 - j];
        // }
        for (var i = arrStr2.length - 1; i >= 0; i--) {
            newArr2[newArr2.length] = arrStr2[i];
        }
        console.log(newArr2);
    </script>
</head>

<body>

</body>

</html>